<?php

class Pay_Model extends CI_Model {
    
	function getPointExchange(){		
		$this->db->from('pointexchange');
		$this->db->select("*");
		$this->db->order_by("money_amount", "asc");
		$query = $this->db->get();
		$rs = array();	
		if($query->num_rows() > 0) {
			$rs = $query->result();	
		}
		return $rs;
	}
    
    function getPlayerPaymentHistory($player_id, $startRecord, $numberRecord){
        
        $this->db->from('playerpaymenthistory');
        $this->db->where("player_id", $player_id);
		$this->db->select("*");
		$this->db->order_by("id", "desc");
        $this->db->limit($numberRecord, $startRecord);
		$query = $this->db->get();
		$rs = array();	
		if($query->num_rows() > 0) {
			$rs = $query->result();	
		}
		return $rs;
    }
    
    function getCount_PlayerPaymentHistory($player_id){
        $this->db->from('playerpaymenthistory');
        $this->db->where("player_id", $player_id);
		$this->db->select("*");
		$this->db->order_by("id", "desc");
		$query = $this->db->get();	
		return $query->num_rows();
    }
    
    function getCountries()
    {
        $this->db->from('countries');
        $this->db->where("active", 0);
		$this->db->select("*");
		$this->db->order_by("name", "asc");
		$query = $this->db->get();	
		return $query->result();
    }
    
    function getStates($country_id)
    {
        $this->db->from('States');
        $this->db->where("country_id", $country_id);
		$this->db->select("*");
		$this->db->order_by("name", "asc");
		$query = $this->db->get();	
		return $query->result();
    }
    
    function getPaymentAccounts($user_id)
    {
        $this->db->from('paymentaccounts');
        $this->db->where("user_id", $user_id);
		$this->db->select("*");
		$this->db->order_by("payment_account_id", "asc");
		$query = $this->db->get();	
		return $query->result();
    }
    
    function getPaymenttransactions($id)
    {
        $this->db->from('paymenttransactions');
        $this->db->where("id", $id);
		$this->db->select("*");
		$query = $this->db->get();
        if($query->num_rows() > 0) {
			$rs = $query->row();	
		}
		return $rs;
    }
    function getAddress($id)
    {
        $this->db->from('addresses');
        $this->db->where("id", $id);
		$this->db->select("*");
		$query = $this->db->get();
        if($query->num_rows() > 0) {
			$rs = $query->row();	
		}
		return $rs;
    }
}